﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../js/jquery.js"></script>
<script type="text/javascript">
$(function(){	
	//顶部导航切换
	$(".nav li a").click(function(){
		$(".nav li a.selected").removeClass("selected")
		$(this).addClass("selected");
	})	
})	
</script>



</head>

<body style="background:url(../images/topbg.gif) repeat-x;">

    <div class="topleft">
    <a href="main.html" target="_parent"><img src="../images/eucLogo.png" title="系统首页" /></a>
    </div>
        
    <ul class="nav" id="topMenu">
    </ul>
            
    <div class="topright">    
    <ul>

    <li><a onclick="logout()" style="cursor:pointer">退出</a></li>
    </ul>
     
    <div class="user">
    <span id="userName">admin</span>
    </div> 
    </div>

<script type="text/javascript">
	var menuData = {};
	$(document).ready(function(){

        $("#userName").html(localStorage.getItem('memberName') );
		 $.ajax({
		        url: '/euc/center/member/function/list',
		        data:'',
		        beforeSend: function(request) {
		            request.setRequestHeader("token",localStorage.getItem('memberToken') );
		        },
		        dataType: 'JSON',
		        async: true,
		        contentType:'application/x-www-form-urlencoded',
		        type: 'POST',
		        success: function (datas, textStatus, response) {
					$("#topMenu").empty();
					$.each(datas,function(i,data){						
						var imageIndex = i+1;
						if(imageIndex > 6){
							imageIndex = 6;
						}
						var menu = $('<li><a functionId="'+data.functionId+'" href="../'+data.action+'" target="rightFrame" class=""><h2>'+data.functionName+'</h2></a></li>');
						$(menu).appendTo($("#topMenu"));
						menuData[data.functionId] = data;
					});
					$(".nav li a").click(function(){
						$(".nav li a.selected").removeClass("selected")
						$(this).addClass("selected");
						window.parent.refreshLeft(menuData[$(this).attr('functionId')]);
					})	
					$(".nav li a").eq(0).trigger("click");
		        },
		        error: function () {
		        	console.log("error");
		        }
		    });
	});

	function logout(){
		localStorage.removeItem('memberToken');
	        localStorage.removeItem('memberDeptId');
	        localStorage.removeItem('memberCompanyName');
	        localStorage.removeItem('memberAdmin');
	        localStorage.removeItem('memberSpaceId');
	        localStorage.removeItem('memberId');
	        localStorage.removeItem('memberName');
	       // window.open('/euc/center/member/login');opener=null;top.close();
	        window.location.href="/euc/center/member/login";
		        window.parent.location.href ="/euc/center/member/login";
	        // window.parent.frames.location.href="/euc/center/member/login"
	}

</script>
</body>
</html>
